package pikes.ecma;

public class FunctionDeclaration extends PrintableSourceElement implements SourceElement {

	private FunctionExpression functionExpression = null;

	public FunctionDeclaration(CharSequence identifier) {
		super();
		this.functionExpression = new FunctionExpression(identifier);
	}

	public void visit(SyntaxTreeVisitor syntaxVisitor) {
		functionExpression.visit(syntaxVisitor);
	}

	public void add(SourceElement sourceElement) {
		functionExpression.add(sourceElement);
	}

	public void add(IExpression expression) {
		functionExpression.add(expression);
	}

	public void add(CharSequence formalParameter) {
		functionExpression.addFormalParameter(formalParameter);
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof FunctionDeclaration)) {
			return false;
		}

		FunctionDeclaration thatFunctionDeclaration = (FunctionDeclaration) obj;

		return functionExpression.equals(thatFunctionDeclaration.functionExpression);
	}

	@Override
	public int hashCode() {
		return functionExpression.hashCode();
	}

}
